package A1_回溯;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class LC_77组合 {
    public static void main(String[] args){
        int n=1,k=1;
//        List<List<Integer>> res=combine(n,k);
//        System.out.println(res);
    }
    LinkedList<Integer> path=new LinkedList<>();
    List<List<Integer>> result=new ArrayList<>();
    public List<List<Integer>> combine(int n, int k) {
        backtracking(n,k,1);
        return result;
    }
    public void backtracking(int n, int k, int startIndex){
        if(path.size()==k){
            result.add(new ArrayList<>(path));
            return;
        }
        for(int i=startIndex;i<=n;i++){
            path.add(i);
            backtracking(n,k,i+1);
            path.removeLast();
        }
    }
}
